/**
 * @author Alexandr Smirnov (luc@hot.ee)
 * 
 * This file is used only if library files are used separately (test cases etc.).
 * Here we print <script> tags for every file in library.
 */

(function() {
	
	var files = [
		"lib/core.js",
		"lib/utils.js",
		"lib/events.js",
		"lib/types/class.js",
		"lib/types/abstractpoint.js",
		"lib/types/xy.js",
		"lib/types/lonlat.js",
		"lib/types/size.js",
		"lib/types/bounds.js",
		"lib/config.js",
		"lib/listeners.js",
		"lib/interface.js",
		"lib/model.js",
		"lib/models/map.js",
		"lib/models/projection.js",
		"lib/view.js",
		"lib/controllers/mousepanning.js"
	];
	
	var base = getCurrentScriptPath();
	
	for (var i=0; i < files.length; i++) {
	    insertScript(base + files[i]);
	}
	
	function getCurrentScriptPath() {
        var scripts = document.getElementsByTagName('script');
        for (var i = 0; i < scripts.length; i++) {
            var src = scripts[i].getAttribute('src');
            var rx = new RegExp('smap\.js$');
			if (src.match(rx)) {
				return src.replace(rx, '');
			}
        }
	}
	
	function insertScript(src) {
	    var script = document.createElement('script'); 
	    script.setAttribute('type', 'text/javascript'); 
	    script.setAttribute('src', src); 
	    var head = document.getElementsByTagName('head')[0]; 
	    head.appendChild(script); 
	}
})();